import request from '@/utils/request'
import { unionApiUrl } from '@/api/config'

export function getList(data) {
    return request({
        url: unionApiUrl + '/news/getPageNews',
        method: 'post',
        data
    })
}

export function getList2(data) {
    return request({
        url: unionApiUrl + '/news/getPageNews2',
        method: 'post',
        data
    })
}

export function getDetail(params) {
    return request({
        url: unionApiUrl + '/news/getNewsById',
        method: 'get',
        params
    })
}

export function getReleaseDetail(params) {
    return request({
        url: unionApiUrl + '/news/getReleaseNewsById',
        method: 'get',
        params
    })
}

export function addData(data) {
    return request({
        url: unionApiUrl + '/news/insertSelective',
        method: 'post',
        data
    })
}

export function updateData(data) {
    return request({
        url: unionApiUrl + '/news/updateByPrimaryKeySelective',
        method: 'post',
        data
    })
}
export function deleteData(params) {
    return request({
        url: unionApiUrl + '/news/deleteByPrimaryKey',
        method: 'get',
        params
    })
}

export function getUnitByOrg(params) {
    return request({
        url: unionApiUrl + '/news/getDepartment',
        method: 'get',
        params
    })
}

/**
 * 修改置顶状态
 * @param {Object} data {id: string, topStatus: Number}      topStatus:  0:未置顶;1:已置顶
 */
export function updateTopStatus(data) {
    return request({
        url: unionApiUrl + '/news/updateTop',
        method: 'post',
        data
    })
}

/**
 * 修改发布状态
 * @param {Object} data {id: string, releaseStatus: Number}      releaseStatus:  0:未发布;1:已发布
 */
export function updateReleaseStatus(data) {
    return request({
        url: unionApiUrl + '/news/updateRelease',
        method: 'post',
        data
    })
}

/**
 * 增加阅读量
 * @param {Object} data
 */
export function increaseReadingQuantity(data) {
    return request({
        url: unionApiUrl + '/news/increaseReadingQuantity',
        method: 'post',
        data
    })
}

/**
 * 获取首页置顶新闻
 * @param {Object} data
 */
export function getHomePageNews(params) {
    return request({
        url: unionApiUrl + '/news/getHomePageNews',
        method: 'get',
        params
    })
}

/**
 * 获取未发布新闻数量
 * @param {Object} data
 */
export function getNoReleaseNewsNum(params) {
    return request({
        url: unionApiUrl + '/news/getNoReleaseNewsNum',
        method: 'get',
        params
    })
}

/**
 * 撤销新闻对象
 * @param {Object} data
 */
export function undoNews(params) {
    return request({
        url: unionApiUrl + '/news/undoNews',
        method: 'get',
        params
    })
}

/**
 * 获取oa新闻链接
 * @param {Object} data
 */
export function getContentById(params) {
    return request({
        url: unionApiUrl + '/news/getContentById',
        method: 'get',
        params
    })
}
